package com.ruijixiang.leetcode.everyday.leetcode2024.leetcode202408;

public class leetcode20240824 {
    public int findPermutationDifference(String s,String t){
        int[] indexA=new int[26];
        int[] indexB=new int[26];
        int n=s.length();
        for(int i=0;i<n;i++){
            indexA[s.charAt(i)-'a']=i;
            indexB[t.charAt(i)-'a']=i;
        }
        int ans=0;
        for(int i=0;i<26;i++){
            ans+=Math.abs(indexA[i]-indexB[i]);
        }
        return ans;
    }
}
